/**
* jQuery EasyUI 1.4.3
* Copyright (c) 2009-2015 www.jeasyui.com. All rights reserved.
*
* Licensed under the GPL license: http://www.gnu.org/licenses/gpl.txt
* To use it on other terms please contact us at info@jeasyui.com
* http://www.jeasyui.com/license_commercial.php
*
* jQuery EasyUI window 扩展
* jeasyui.extensions.window.autoCenter.js
* 开发 流云
* 由 落阳 整理
* 最近更新：2015-11-14
*
* 依赖项：
*   1、jquery.jdirk.js
*
* Copyright (c) 2015 ChenJianwei personal All rights reserved.
*/
$(function () {

    //  设置当屏幕大小调整时，所有 easyui-window 或 easyui-dialog 窗口在属性 hcenter: true 或 vcenter: true 的情况下自动居中。
    $(window).resize(function () {
        $(".window-body").each(function () {
            var t = $(this),
                state = $.data(this, "window");
            if (!state || !state.options) {
                return;
            }
            var opts = t.window("options");
            if (opts.draggable) {
                if (opts.hcenter || opts.vcenter) {
                    var method = opts.hcenter && opts.vcenter
                        ? "center"
                        : (opts.hcenter ? "hcenter" : "vcenter");
                    t.window(method);
                } else if (opts.inlocale) {
                    t.window("move");
                }
            }
        });
    });

});


(function ($) {

    $.util.namespace("$.fn.window.extensions");

    var methods = {

    };

    var defaults = {

        //  扩展 easyui-window 以及 easyui-dialog 控件的自定义属性，表示该窗口对象是否在屏幕大小调整的情况下自动进行左右居中，默认为 false。
        hcenter: false,

        //  扩展 easyui-window 以及 easyui-dialog 控件的自定义属性，表示该窗口对象是否在屏幕大小调整的情况下自动进行上下居中，默认为 false。
        vcenter: false
    };

    var compent = $.fn.window;
    if (compent.extensions.defaults) {
        $.extend(compent.extensions.defaults, defaults);
    } else {
        compent.extensions.defaults = defaults;
    }

    if (compent.extensions.methods) {
        $.extend(compent.extensions.methods, methods);
    } else {
        compent.extensions.methods = methods;
    }

    $.extend(compent.defaults, defaults);
    $.extend(compent.methods, methods);

})(jQuery);
/**
* jQuery EasyUI 1.4.3
* Copyright (c) 2009-2015 www.jeasyui.com. All rights reserved.
*
* Licensed under the GPL license: http://www.gnu.org/licenses/gpl.txt
* To use it on other terms please contact us at info@jeasyui.com
* http://www.jeasyui.com/license_commercial.php
*
* jQuery EasyUI window 扩展
* jeasyui.extensions.window.autoRestore.js
* 开发 流云
* 由 落阳 整理
* 最近更新：2015-11-15
*
* 依赖项：
*   1、jquery.jdirk.js
*
* Copyright (c) 2015 ChenJianwei personal All rights reserved.
*/
(function ($) {

    $.util.namespace("$.fn.window.extensions");


    function initialize(target) {
        var state = $.data(target, "window");
        if (!state._inited) {
            initHeaderDblClick(target);
            state._inited = true;
        }
    }

    function initHeaderDblClick(target) {
        var t = $(target),
            header = t.window("header");
        header.unbind("dblclick.window-extensions").bind("dblclick.window-extensions", function () {
            var opts = t.window("options");
            if (opts.autoRestore) {
                if (opts.maximized) {
                    t.window("restore");
                } else if (opts.maximizable) {
                    t.window("maximize");
                }
            }
        });
    }


    var _window = $.fn.window;
    $.fn.window = function (options, param) {
        if (typeof options == "string") {
            return _window.apply(this, arguments);
        }
        options = options || {};
        return this.each(function () {
            var jq = $(this),
                isInited = $.data(this, "window") ? true : false,
                opts = isInited ? options : $.extend({},
                    $.fn.window.parseOptions(this),
                    $.parser.parseOptions(this, [{
                        autoRestore: "boolean"
                    }]), options);
            _window.call(jq, opts, param);
            if (!isInited) {
                initialize(this);
            }
        });
    };
    $.union($.fn.window, _window);

    var methods = {

    };

    var defaults = {

        //  扩展 easyui-window 以及 easyui-dialog 控件的自定义属性，表示该窗口是否在双击头部时自动 最大化 或 恢复原尺寸。
        autoRestore: true
    };

    var compent = $.fn.window;
    if (compent.extensions.defaults) {
        $.extend(compent.extensions.defaults, defaults);
    } else {
        compent.extensions.defaults = defaults;
    }

    if (compent.extensions.methods) {
        $.extend(compent.extensions.methods, methods);
    } else {
        compent.extensions.methods = methods;
    }

    $.extend(compent.defaults, defaults);
    $.extend(compent.methods, methods);

})(jQuery);
/**
* jQuery EasyUI 1.4.3
* Copyright (c) 2009-2015 www.jeasyui.com. All rights reserved.
*
* Licensed under the GPL license: http://www.gnu.org/licenses/gpl.txt
* To use it on other terms please contact us at info@jeasyui.com
* http://www.jeasyui.com/license_commercial.php
*
* jQuery EasyUI window 扩展
* jeasyui.extensions.window.closeOnEsc.js
* 开发 流云
* 由 落阳 整理
* 最近更新：2015-11-15
*
* 依赖项：
*   1、jquery.jdirk.js
*
* Copyright (c) 2015 ChenJianwei personal All rights reserved.
*/
(function ($) {

    $.util.namespace("$.fn.window.extensions");


    $(function () {
        //  在当前打开 modal:true 的 easyui-window 或者 easyui-dialog 时，按 ESC 键关闭顶层的 easyui-window 或者 easyui-dialog 对象。
        $(document).keydown(function (e) {
            if (e.which != 27) {
                return;
            }

            var items = $("div.window-mask:visible");
            if (!items.length) {
                return;
            }
            var item = $.array.max(items, function (a, b) {
                return $(a).css("zindex") - $(b).css("zindex");
            })
            $(item).prevAll("div.panel.window:first").children(".window-body").each(function () {
                if (!$.data(this, "window")) {
                    return;
                }
                var t = $(this),
                    opts = t.window("options");
                if (opts && opts.closable && opts.closeOnEsc && !t.window("header").find(".panel-tool a").attr("disabled")) {
                    t.window("close");
                }
            });
        });
    });

    var methods = {

    };

    var defaults = {

        //  扩展 easyui-window 以及 easyui-dialog 控件的自定义属性，表示该窗口为模式窗口时，是否在按下 ESC 时关闭该窗口，默认为 true。
        //  落阳注：要使该自定义属性有效，window/dialog 的options中，modal 属性和 closable 属性必须为 true 。
        closeOnEsc: true
    };

    var compent = $.fn.window;
    if (compent.extensions.defaults) {
        $.extend(compent.extensions.defaults, defaults);
    } else {
        compent.extensions.defaults = defaults;
    }

    if (compent.extensions.methods) {
        $.extend(compent.extensions.methods, methods);
    } else {
        compent.extensions.methods = methods;
    }

    $.extend(compent.defaults, defaults);
    $.extend(compent.methods, methods);

})(jQuery);
/**
* jQuery EasyUI 1.4.3
* Copyright (c) 2009-2015 www.jeasyui.com. All rights reserved.
*
* Licensed under the GPL license: http://www.gnu.org/licenses/gpl.txt
* To use it on other terms please contact us at info@jeasyui.com
* http://www.jeasyui.com/license_commercial.php
*
* jQuery EasyUI window 扩展
* jeasyui.extensions.window.shine.js
* 开发 流云
* 由 落阳 整理
* 最近更新：2015-11-13
*
* 依赖项：
*   1、jquery.jdirk.js
*
* Copyright (c) 2015 ChenJianwei personal All rights reserved.
*/
(function ($) {

    $(function () {

        //  点击模式（options.modal = true）对话框（例如 easyui-messager、easyui-window、easyui-dialog）的背景遮蔽层使窗口闪动
        $("body").on("click", "div.window-mask", function (e) {
            $(this).prevAll("div.panel.window:first").shine(125, 6);
        });

    });

})(jQuery);

/**
* jQuery EasyUI 1.4.3
* Copyright (c) 2009-2015 www.jeasyui.com. All rights reserved.
*
* Licensed under the GPL license: http://www.gnu.org/licenses/gpl.txt
* To use it on other terms please contact us at info@jeasyui.com
* http://www.jeasyui.com/license_commercial.php
*
* jQuery EasyUI window bug修复
* jeasyui.fixeds.window.cls.js
* 开发 流云
* 由 落阳 整理
* 最近更新：2015-11-15
*
* 依赖项：
*   1、jquery.jdirk.js
*
* Copyright (c) 2015 ChenJianwei personal All rights reserved.
*/
(function ($) {

    $.util.namespace("$.fn.window.extensions");

    function initialize(target) {
        var state = $.data(target, "window");
        if (!state._inited) {
            initCls(target);
            state._inited = true;
        }
    }

    function initCls(target) {
        var t = $(target),
            opts = t.window("options"),
            header = t.window("header"),
            body = t.window("body");

        if (opts.bodyCls) {
            body.addClass(opts.bodyCls);
        }
        if (opts.headerCls) {
            header.addClass(opts.headerCls);
        }
    }

    var _window = $.fn.window;
    $.fn.window = function (options, param) {
        if (typeof options == "string") {
            return _window.apply(this, arguments);
        }
        options = options || {};
        return this.each(function () {
            var jq = $(this),
                isInited = $.data(this, "window") ? true : false,
                opts = isInited ? options : $.extend({},
                    $.fn.window.parseOptions(this), options);
            _window.call(jq, opts, param);
            if (!isInited) {
                initialize(this);
            }
        });
    };
    $.union($.fn.window, _window);

    var methods = {

    };

    var defaults = {

    };

    var compent = $.fn.window;
    if (compent.extensions.defaults) {
        $.extend(compent.extensions.defaults, defaults);
    } else {
        compent.extensions.defaults = defaults;
    }

    if (compent.extensions.methods) {
        $.extend(compent.extensions.methods, methods);
    } else {
        compent.extensions.methods = methods;
    }

    $.extend(compent.defaults, defaults);
    $.extend(compent.methods, methods);

})(jQuery);